package com.itheima.ExtendsDemo;
public class Test {
    public static void main(String[] args) {
        //向上转型
        Animals animals=new Dog();
        animals.eat();
        //向下转型
        if (animals instanceof Dog){
            Dog dog=(Dog) animals;
            dog.roar();
        }
        else  if (animals instanceof Cat){
            Cat cat=(Cat)animals;
            cat.eat();
        }

    }
}
